function getChildren(parentDepId, departments) {
	if (parentDepId) {
		var temp = new Array();
		for ( var int = 0; int < departments.length; int++) {
			var dep = departments[int];
			if (dep.parentdepid == parentDepId) {
				var children = getChildren(dep.id, departments);
				temp.push({"id":dep.id,"text":dep.depname,"attributes":{"department":dep},"children":children});
			}
		}
		return temp;
	}
	return null;
}